package day13.KeJian;

import java.io.*;

public class BufferedStreamDemo01 {
    public static void main(String[] args) throws IOException {
        m1();
        //BufferedReader(Reader in)
        BufferedReader br = new BufferedReader(new FileReader("D://itheima//nb.txt"));
        m2(br);
        m3(br);
    }

    private static void m3(BufferedReader br) throws IOException {
        char[] chr = new char[1024];
        int len;
        while ((len=br.read(chr))!=-1){
            System.out.println(new String(chr,0,len));
        }
        br.close();
    }

    private static void m2(BufferedReader br) throws IOException {
        int ch;
        while ((ch=br.read())!=-1){
            System.out.println((char)ch);
        }
        br.close();
    }

    private static void m1() throws IOException {
        //BufferedWriter(Writer out)
        BufferedWriter bw = new BufferedWriter(new FileWriter("D://itheima//nb.txt"));
        bw.write("hello\r\n");
        bw.write("123456/r/n");
        bw.close();
       /* //BufferedReader(Reader in)
        BufferedReader br = new BufferedReader(new FileReader("D://itheima//nb.txt"));
        int ch;
        while ((ch = br.read())!=-1){
            System.out.println((char)ch);
        }
        br.close();*/
    }
}
